package org.cancan.demo.panel;

public class Start {

    public static void main(String[] args) {
        // 创建并显示窗口
        CameraFrame frame = new CameraFrame();

        // 创建并启动视频捕获线程
        VideoCaptureThread videoCaptureThread = new VideoCaptureThread(frame);
        Thread thread = new Thread(videoCaptureThread);
        thread.start();

        // 添加一个关闭钩子以正确关闭线程
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            videoCaptureThread.stop();
            try {
                thread.join(); // 等待线程终止
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }));
    }
}
